package top.wugy.blog.model;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;
import top.wugy.blog.kits.Const;

import java.util.List;

/**
 * wugy on 2017/11/2 17:09
 */
public class TTag extends Model<TTag> implements IBean {

    public static final TTag dao = new TTag();

    public TTag setId(Integer id) {
        return set("id", id);
    }

    public Integer getId() {
        return get("id");
    }

    public String getName() {
        return get("name");
    }

    public TTag setName(String name) {
        return set("name", name);
    }

    public TTag findByName(String tagName) {
        return findFirst("select * from " + Const.TABLE_TAG + " where name = ?", tagName);
    }

    public List<Record> findAll() {
        return Db.find("select * from " + Const.TABLE_TAG);
    }
}
